<?php
/**
 * @Notes:【】
 * @Date: 2022-06-08 23:00
 */

namespace App\Controller\Admin\Task;

use App\Controller\Admin\BaseController;
use App\Middleware\CheckAdminMiddleware;
use App\Service\Task\TaskHelpService;
use App\Service\Task\TaskReportService;
use App\Service\Task\TaskService;
use App\Service\Task\TaskTypesService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Middleware;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;

/**
 * @ApiController(prefix="admin/task/report")
 * @Middleware(CheckAdminMiddleware::class)
 */
class TaskReportController extends BaseController
{
    /**
     * @Inject()
     * @var TaskReportService
     */
    protected $taskReportService;

    /**
     * @Notes:【】
     * @Date: 2022-06-08 23:22
     * @PostApi(path="lists")
     */
    public function lists()
    {
        $params = $this->getParams();
        $data = $this->taskReportService->lists($params);
        _SUCCESS($data);
    }

    /**
     * @Notes:【】
     * @Date: 2022-06-08 23:22
     * @PostApi(path="add")
     * @FormData(key="desc")
     * @FormData(key="image_id")
     * @FormData(key="title")
     */
    public function add()
    {
        $params = $this->getData(false);
        $data = $this->taskReportService->add($params);
        _SUCCESS($data);
    }

    /**
     * @Notes:【】
     * @Date: 2022-06-08 23:22
     * @PostApi(path="edit")
     * @FormData(key="id")
     * @FormData(key="desc")
     * @FormData(key="image_id")
     * @FormData(key="title")
     */
    public function edit()
    {
        $params = $this->getData(false);
        $data = $this->taskReportService->edit($params);
        _SUCCESS($data);
    }


    /**
     * @Notes:【】
     * @Date: 2022-06-08 23:22
     * @PostApi(path="del")
     * @FormData(key="id")
     */
    public function del()
    {
        $params = $this->getData(false);
        $data = $this->taskReportService->del($params->get('id'));
        _SUCCESS();
    }

    /**
     * @PostApi(path="set-status")
     * @FormData(key="id")
     * @FormData(key="status")
     * @FormData(key="reason")
     */
    public function setStatus(){
        $params = $this->getParams();
        $this->taskReportService->setStatus($params->get('id'),$params->except('id'));
        _SUCCESS();
    }
}